'''
首次进入APP广告弹窗
'''
from appium.webdriver.common.mobileby import MobileBy
from Base.basepage import BasePage
from common.LoggerUtil import LogUtils


class IndexImgPage(BasePage):
    loc_image_index = (MobileBy.ID, "com.youth.startup:id/image_index")
    loc_image_cancle = (MobileBy.ID, "com.youth.startup:id/image_cancle")

    def index_img_page(self):
        try:
            res_img = self.locator(self.loc_image_index)
            while True:
                if res_img is not None :
                    LogUtils.info('首页广告弹窗存在')
                    self.locator(self.loc_image_cancle).click()
                    break
                else:
                    LogUtils.info('首页广告弹窗不存在！')
                break
        except Exception as e:
            LogUtils.error(f"----首页无广告弹窗，正常执行测试用例: {e}")
